package com.hnnu.shoppingtoghter.demo.service.impl;

import com.github.pagehelper.PageHelper;
import com.hnnu.shoppingtoghter.demo.entity.Project;
import com.hnnu.shoppingtoghter.demo.entity.SysUser;
import com.hnnu.shoppingtoghter.demo.mapper.ProjectMapper;
import com.hnnu.shoppingtoghter.demo.service.ProjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.servlet.http.HttpSession;
import java.beans.Transient;
import java.util.List;

/**
 * @Description:
 * @Author: liu_cheng_xi
 * @CreateTime： 2022/7/1 8:42
 */
@Service
public class ProjectServiceImpl implements ProjectService {


    @Autowired
    private ProjectMapper projectMapper;

    /**
     * @param project
     * @Description: 查询商品
     * @Author: liu_cheng_xi
     * @CreateTime: 2022/7/1 8:43
     * @param: null
     * @return: null
     */
    @Override
    public List<Project> selectListByProject(Project project) {
        PageHelper.startPage(project.getPage(),project.getRow());
        List<Project> projectList = projectMapper.selectListByProject(project);
        return projectList;
    }

    /**
     * @param project
     * @Description: 将商品对象插入到表里
     * @Author: liu_cheng_xi
     * @CreateTime: 2022/7/4 11:20
     * @param: null
     * @return: null
     */
    @Override
    public int insertProject(Project project) {
        project.setCommodityState(0);
        return projectMapper.insertProject(project);
    }

    /**
     * @param commodityId
     * @Description: 根据商品ID 获取数据库的商品全部信息 进行更新
     * @Author: liu_cheng_xi
     * @CreateTime: 2022/7/5 11:15
     * @param: null
     * @return: null
     */
    @Override
    public Project selectProjectById(Integer commodityId) {
        return projectMapper.selectProjectById(commodityId);
    }

    /**
     * @param project
     * @Description: 通过商品ID来对对应的商品进行更新
     * @Author: liu_cheng_xi
     * @CreateTime: 2022/7/5 21:38
     * @param: null
     * @return: null
     */

    @Override
    public int Update(Project project) {
        return projectMapper.Update(project);
    }

    /**
     * @param commodityId
     * @Description: 删除商品
     * @Author: liu_cheng_xi
     * @CreateTime: 2022/7/6 15:28
     * @param: commodityId
     * @return: int
     */
    @Override
    public int DeleteProject(Integer commodityId) {
        int rows = projectMapper.DeleteProject(commodityId);
        return rows;
    }

    /**
     * @param project
     * @Description: TODO
     * @Author: liu_cheng_xi
     * @CreateTime: 2022/7/6 22:50
     * @param: null
     * @return: null
     */
    @Override
    public List<Project> selectProjectByUser(Project project) {

        return projectMapper.selectProjectByUser(project);
    }


}
